using System.ComponentModel.DataAnnotations;

namespace ConsoleApi.Models
{
    /// <summary>
    /// 分页查询基类
    /// </summary>
    public class PagedQueryDto
    {
        /// <summary>
        /// 页码（从1开始）
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 页大小
        /// </summary>
        public int PageSize { get; set; } = 10;

        /// <summary>
        /// 搜索关键字
        /// </summary>
        public string? Keyword { get; set; }
    }

    /// <summary>
    /// 分页结果
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PagedResultDto<T>
    {
        /// <summary>
        /// 数据列表
        /// </summary>
        public List<T> Items { get; set; } = new();

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
    }

    /// <summary>
    /// 通知公告查询DTO
    /// </summary>
    public class AnnouncementQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 公告类型
        /// </summary>
        public string? Type { get; set; }

        /// <summary>
        /// 是否激活
        /// </summary>
        public bool? IsActive { get; set; }
    }

    /// <summary>
    /// 通知公告DTO
    /// </summary>
    public class AnnouncementDto
    {
        public int Id { get; set; }
        public string Content { get; set; } = string.Empty;
        public string Type { get; set; } = string.Empty;
        public int Priority { get; set; }
        public bool IsActive { get; set; }
        public DateTime? PublishTime { get; set; }
        public DateTime? ExpiryTime { get; set; }
        public string? Publisher { get; set; }
        public string? TargetUserGroup { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 采购订单查询DTO
    /// </summary>
    public class PurchaseOrderQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 订单状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 订单类型
        /// </summary>
        public string? OrderType { get; set; }
    }

    /// <summary>
    /// 采购订单DTO
    /// </summary>
    public class PurchaseOrderDto
    {
        public int Id { get; set; }
        public string OrderNumber { get; set; } = string.Empty;
        public string Subject { get; set; } = string.Empty;
        public string OrderType { get; set; } = string.Empty;
        public string Status { get; set; } = string.Empty;
        public decimal TotalAmount { get; set; }
        public int? SupplierId { get; set; }
        public string? SupplierName { get; set; }
        public DateTime? ExpectedArrivalDate { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 生产工单查询DTO
    /// </summary>
    public class ProductionOrderQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 工单状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 负责人
        /// </summary>
        public string? ResponsiblePerson { get; set; }
    }

    /// <summary>
    /// 生产工单DTO
    /// </summary>
    public class ProductionOrderDto
    {
        public int Id { get; set; }
        public string OrderNumber { get; set; } = string.Empty;
        public string ProductionItem { get; set; } = string.Empty;
        public string Status { get; set; } = string.Empty;
        public DateTime? PlannedStartTime { get; set; }
        public DateTime? PlannedIntroTime { get; set; }
        public DateTime? ActualStartTime { get; set; }
        public DateTime? ActualCompletionTime { get; set; }
        public string? ResponsiblePerson { get; set; }
        public int PlannedQuantity { get; set; }
        public int ActualQuantity { get; set; }
        public int Priority { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 销售订单查询DTO
    /// </summary>
    public class ProductionSalesOrderQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 订单状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 客户名称
        /// </summary>
        public string? CustomerName { get; set; }
    }

    /// <summary>
    /// 销售订单DTO
    /// </summary>
    public class ProductionSalesOrderDto
    {
        public int Id { get; set; }
        public string OrderNumber { get; set; } = string.Empty;
        public string Subject { get; set; } = string.Empty;
        public string OrderType { get; set; } = string.Empty;
        public string Status { get; set; } = string.Empty;
        public DateTime? DeliveryDate { get; set; }
        public decimal TotalAmount { get; set; }
        public int? CustomerId { get; set; }
        public string? CustomerName { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 审批单据查询DTO
    /// </summary>
    public class ApprovalDocumentQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 单据类型
        /// </summary>
        public string? DocumentType { get; set; }

        /// <summary>
        /// 审批状态
        /// </summary>
        public string? Status { get; set; }
    }

    /// <summary>
    /// 审批单据DTO
    /// </summary>
    public class ApprovalDocumentDto
    {
        public int Id { get; set; }
        public string DocumentType { get; set; } = string.Empty;
        public int DocumentId { get; set; }
        public string? DocumentNumber { get; set; }
        public string Status { get; set; } = string.Empty;
        public int Priority { get; set; }
        public string? Applicant { get; set; }
        public DateTime? ApplicationTime { get; set; }
        public string? Approver { get; set; }
        public DateTime? ApprovalTime { get; set; }
        public string? ApprovalComments { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 核心指标DTO
    /// </summary>
    public class CoreMetricsDto
    {
        public int Id { get; set; }
        public DateTime Date { get; set; }
        public decimal SalesRevenue { get; set; }
        public int SalesOrderCount { get; set; }
        public decimal Collection { get; set; }
        public decimal PurchaseExpense { get; set; }
        public int PurchaseOrderCount { get; set; }
        public decimal PaidAmount { get; set; }
        public string? Remarks { get; set; }
    }

    /// <summary>
    /// 统计数据查询DTO
    /// </summary>
    public class StatisticsQueryDto
    {
        /// <summary>
        /// 开始日期
        /// </summary>
        public DateTime? StartDate { get; set; }

        /// <summary>
        /// 结束日期
        /// </summary>
        public DateTime? EndDate { get; set; }

        /// <summary>
        /// 统计类型
        /// </summary>
        public string? Type { get; set; }

        /// <summary>
        /// 时间范围
        /// </summary>
        public string? TimeRange { get; set; }
    }

    /// <summary>
    /// 统计数据DTO
    /// </summary>
    public class StatisticsDto
    {
        public int Id { get; set; }
        public DateTime Date { get; set; }
        public string Type { get; set; } = string.Empty;
        public decimal OrderAmount { get; set; }
        public int OrderCount { get; set; }
        public string? TimeRange { get; set; }
        public string? Remarks { get; set; }
    }

    /// <summary>
    /// 仓库查询DTO
    /// </summary>
    public class WarehouseQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 仓库类型
        /// </summary>
        public string? WarehouseType { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public string? Status { get; set; }
    }

    /// <summary>
    /// 仓库DTO
    /// </summary>
    public class WarehouseDto
    {
        public int Id { get; set; }
        public string WarehouseName { get; set; } = string.Empty;
        public string? Location { get; set; }
        public string? WarehouseType { get; set; }
        public string? Manager { get; set; }
        public string? ContactPhone { get; set; }
        public string Status { get; set; } = string.Empty;
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 生产物品查询DTO
    /// </summary>
    public class ProductionItemQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 物品类型
        /// </summary>
        public string? ItemType { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public int? WarehouseId { get; set; }
    }

    /// <summary>
    /// 生产物品DTO
    /// </summary>
    public class ProductionItemDto
    {
        public int Id { get; set; }
        public string ItemNumber { get; set; } = string.Empty;
        public string ItemName { get; set; } = string.Empty;
        public string? BatchNumber { get; set; }
        public DateTime? ProductionDate { get; set; }
        public DateTime? ExpiryDate { get; set; }
        public int? WarehouseId { get; set; }
        public string? WarehouseName { get; set; }
        public int InventoryQuantity { get; set; }
        public string? ItemType { get; set; }
        public string? Specification { get; set; }
        public string? Unit { get; set; }
        public decimal? UnitPrice { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 工序查询DTO
    /// </summary>
    public class ProcessQueryDto : PagedQueryDto
    {
        /// <summary>
        /// 工序状态
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 工序类型
        /// </summary>
        public string? ProcessType { get; set; }
    }

    /// <summary>
    /// 工序DTO
    /// </summary>
    public class ProcessDto
    {
        public int Id { get; set; }
        public string DocumentNumber { get; set; } = string.Empty;
        public string ProcessName { get; set; } = string.Empty;
        public string Status { get; set; } = string.Empty;
        public DateTime? PlannedStartTime { get; set; }
        public DateTime? PlannedIntroTime { get; set; }
        public DateTime? ActualStartTime { get; set; }
        public DateTime? ActualCompletionTime { get; set; }
        public string? ResponsiblePerson { get; set; }
        public string? ProcessType { get; set; }
        public string? Description { get; set; }
        public int Priority { get; set; }
        public string? Remarks { get; set; }
        public DateTime CreateTime { get; set; }
        public string? Creator { get; set; }
    }

    /// <summary>
    /// 图表数据DTO
    /// </summary>
    public class ChartDataDto
    {
        /// <summary>
        /// 时间标签（X轴）
        /// </summary>
        public List<string> TimeLabels { get; set; } = new();

        /// <summary>
        /// 订单金额数据（Y轴）
        /// </summary>
        public List<decimal> OrderAmounts { get; set; } = new();

        /// <summary>
        /// 订单数量数据（Y轴）
        /// </summary>
        public List<int> OrderCounts { get; set; } = new();

        /// <summary>
        /// 时间范围
        /// </summary>
        public string TimeRange { get; set; } = string.Empty;

        /// <summary>
        /// 统计类型（sales/purchase）
        /// </summary>
        public string Type { get; set; } = string.Empty;
    }
} 